# Maintainer: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
# Contributor: Lev Lybin <lev.lybin@gmail.com>
# Contributor: Vadym Abramchuk <abramm@gmail.com>
# Contributor: John Gerritse <reaphsharc@gmail.com>

pkgname=gearmand
pkgver=1.1.21
pkgrel=1
pkgdesc="Distributed job queue server."
arch=('loong64' 'x86_64')
depends=('libevent' 'boost-libs' 'mariadb-libs' 'postgresql-libs' 'sqlite' 'hiredis')
makedepends=('boost' 'gperf' 'python-sphinx')
conflicts=('gearman')
replaces=('gearman')
provides=("gearman=$pkgver")
url="http://gearman.org/"
license=('CUSTOM')
backup=('etc/gearmand.conf')
source=(https://github.com/gearman/$pkgname/releases/download/$pkgver/$pkgname-$pkgver.tar.gz
        gearmand.service
        gearmand.conf
        user.conf)
sha256sums=('2688b83e48f26fdcd4fbaef2413ff1a76c9ecb067d1621d0e0986196efecd308'
            'dee38ad4e614969047253b8c4996b8cdf33c981b0df215b6627356fd4cbafa33'
            '6c14fdcd94105338e13bdd59dbed4f9b77430a517b2c125ac2e6d3bc43bdf506'
            '02f11878d7c32039385586e527006f5cbb08444007f6c72a012e8acd8a855aef')

build() {
  cd "$srcdir"/$pkgname-$pkgver
  export LDFLAGS="$LDFLAGS -lboost_system"
  ./configure \
    --prefix=/usr \
    --sbindir=/usr/bin \
    --sysconfdir=/etc \
    --localstatedir=/run \
    --disable-static \
    --enable-ssl
  make
}

package() {
  cd "$srcdir"/$pkgname-$pkgver
  make DESTDIR="$pkgdir" install
  install -Dm644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING

  cd "$srcdir"
  install -Dm644 gearmand.service "$pkgdir"/usr/lib/systemd/system/gearmand.service
  install -Dm644 gearmand.conf "$pkgdir"/etc/gearmand.conf
  install -Dm644 user.conf "$pkgdir"/usr/lib/sysusers.d/gearmand.conf
}
